Skip to content

Feat/zipcode soft refresh query allowlist#760

Open
hiagolcm wants to merge 4 commits into
masterfrom
feat/zipcode-soft-refresh-query-allowlist
Open

Feat/zipcode soft refresh query allowlist#760
hiagolcm wants to merge 4 commits into
masterfrom
feat/zipcode-soft-refresh-query-allowlist

Conversation

@hiagolcm

Copy link
Copy Markdown
Contributor

What problem is this solving?

How to test it?

[Workspace](Link goes here!)

Screenshots or example usage:

Describe alternatives you've considered, if any.

Related to / Depends on

How does this PR make you feel? 🔗

![](put .gif link here - can be found under "advanced" on giphy)

hiagolcm and others added 4 commits June 11, 2026 09:15
…clear

Co-authored-by: Cursor <cursoragent@cursor.com>
…clear

When vtex.delivery-promise-components clears the `page` query param
through render-runtime after a location change, the useFetchMore reducer
was left on the stale page. A shopper on page 5 would see page-1 results
but the next "load more" fetched page 6. Detect the external transition
(`runtimeQuery.page` going absent/1 while the reducer is past page 1) and
dispatch RESET so the next "load more" correctly fetches page 2. Shopper-
driven "load more"/"fetch previous" and initial mount are unaffected.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
With enableLazySearchQuery on and maxItemsPerPage > 18, SearchQuery
fetches the first 18 items and lazily loads items 18..N-1 once. An
external refetch (vtex.delivery-promise-components location change) resets
the Apollo cache to the initial 18-item window, but lazyItemsRemaining was
already consumed at mount — items 18..N-1 would never be fetched again,
leaving a permanent gap before the next "load more" page.

The new useLazyItemsRearm hook detects the cached list shrinking back to
(or below) the initial window while on the first page and resets
lazyItemsRemaining, re-triggering the existing 500ms lazy-refill effect.
Guards prevent false positives on initial mount, list growth, empty lists,
and pages past the first.

Co-authored-by: Cursor <cursoragent@cursor.com>
@hiagolcm hiagolcm requested review from a team as code owners June 11, 2026 12:21
@hiagolcm hiagolcm requested review from RodrigoTadeuF, gabpaladino and leo-prange-vtex and removed request for a team June 11, 2026 12:21
@vtex-io-ci-cd

vtex-io-ci-cd Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖

Please select which version do you want to release:

  • Patch (backwards-compatible bug fixes)

  • Minor (backwards-compatible functionality)

  • Major (incompatible API changes)

And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.

  • No thanks, I would rather do it manually 😞

@vtex-io-docs-bot

Copy link
Copy Markdown

Beep boop 🤖

I noticed you didn't make any changes at the docs/ folder

  • There's nothing new to document 🤔
  • I'll do it later 😞

In order to keep track, I'll create an issue if you decide now is not a good time

  • I just updated 🎉🎉

@chrsmutti chrsmutti left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very familiar with the lazyItems stuff, but it looks right! Just have a nitpick on the Changelog.

rerender({ ...baseProps, page: 5 })
})

expect(result.current.nextPage).toBe(6)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡

Shouldn't this be 7? 🤔

Comment thread CHANGELOG.md

### Fixed

- `useFetchMore` (gallery "load more"): the in-memory pagination reducer now resets to the first page when the `page` query param is **externally** brought back to page 1 (e.g. `vtex.delivery-promise-components` clearing it through render-runtime after a zipcode / pickup-point change). Previously, because the reducer is seeded once at mount and only resets on `query`/`map`/`orderBy`/`priceRange` changes, a location change left it on the stale page: a shopper on page 5 would see page-1 results but the next "load more" fetched page 6 (and the URL showed `page=6`). The reset fires only on an external transition to the first page while the reducer is past it, so the shopper's own "load more"/"fetch previous" navigation and initial mount are unaffected.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡

I'd prefer to make this cleaner, single sentences. And move the "Why?" to the PR description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants